home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / matrix.ph < prev    next >
Text File  |  1994-04-25  |  6KB  |  166 lines

  1. /*****************************************************************************
  2.   FILE           : matrix.ph
  3.   SHORTNAME      : 
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS-Kernel standard matrix operations
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Michael Vogt
  10.   DATE           : 10.02.92
  11.  
  12.   CHANGED BY     : Sven Doering
  13.   IDENTIFICATION : @(#)matrix.ph    1.7 3/15/94
  14.   SCCS VERSION   : 1.7
  15.   LAST CHANGE    : 3/15/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20.  
  21. #ifndef    _RBF_MATRIX_DEFINED_
  22. #define _RBF_MATRIX_DEFINED_
  23.  
  24. /* begin global definition section */
  25.  
  26. /************************************************************************/
  27. /* type definitions:                            */
  28. /************************************************************************/
  29.  
  30. typedef struct
  31. {
  32.     int    rows;        /* number of rows            */
  33.     int    columns;    /* number of columns            */
  34.     float    *field;        /* matrix organized as list        */
  35.     float    **r_pt;        /* array of references to rows        */
  36. } RbfFloatMatrix;
  37.  
  38. /************************************************************************/
  39. /* allocate matrix m with r rows and c columns                */
  40. /* returns 0 if impossible, 1 otherwise                    */
  41. /************************************************************************/
  42.  
  43. int    RbfAllocMatrix(int r, int c, RbfFloatMatrix *m);
  44.  
  45. /************************************************************************/
  46. /* deallocate matrix m                            */
  47. /************************************************************************/
  48.  
  49. void    RbfFreeMatrix(RbfFloatMatrix *m);
  50.  
  51. /************************************************************************/
  52. /* set all elements of matrix m to value c                */
  53. /************************************************************************/
  54.  
  55. void    RbfClearMatrix(RbfFloatMatrix *m, double c);
  56.  
  57. /************************************************************************/
  58. /* returns the square norm of  matrix m                             */
  59. /************************************************************************/
  60.  
  61. float    RbfSquareOfNorm(RbfFloatMatrix *m);
  62.  
  63. /************************************************************************/
  64. /* sets m to the idempotent matrix                           */
  65. /************************************************************************/
  66.  
  67. void    RbfIdempotentMatrix(RbfFloatMatrix *m);
  68.  
  69. /************************************************************************/
  70. /* multiplies matrix m with a constant factor                  */
  71. /************************************************************************/
  72.  
  73. void    RbfMulScalarMatrix(RbfFloatMatrix *m, float a);
  74.  
  75.  
  76. /************************************************************************/
  77. /* set m1 to m2 (m1 = m2). m1 must be allocated with the same        */
  78. /* dimensions as m2                            */
  79. /************************************************************************/
  80.  
  81. void    RbfSetMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  82.  
  83. /************************************************************************/
  84. /* set m1 to m2 transposed (m1 = m2T)                    */
  85. /* number of rows of m1 must be equal to number of columns of m2.    */
  86. /* number of columns of m1 must be equal to number of rows of m2.    */
  87. /************************************************************************/
  88.  
  89. void    RbfTranspMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  90.  
  91. /************************************************************************/
  92. /* set m to inverse of m (m = m^-1).                    */
  93. /* returns 0 if impossible, 1 otherwise, negative if kernel error    */
  94. /************************************************************************/
  95.  
  96. int    RbfInvMatrix(RbfFloatMatrix *m);
  97.  
  98. /************************************************************************/
  99. /* function RbfMulTranspMatrix:                        */
  100. /* set m1 to m2*m2T. number of rows of m2 must be equal to number of    */
  101. /* rows and columns of m1.                                              */
  102. /************************************************************************/
  103.  
  104. void    RbfMulTranspMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  105.  
  106. /************************************************************************/
  107. /* set m1 to m2*m3. number of columns of m2 must be equal to number of  */
  108. /* rows of m3. m1 must be allocated with r = number of rows of m2 and   */
  109. /* c = number of columns of m3.                        */
  110. /************************************************************************/
  111.  
  112. void    RbfMulMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2, RbfFloatMatrix *m3); 
  113.  
  114. /************************************************************************/
  115. /* set m1 to m2+m3. number of columns of m1, m2 and m3 must be equal.    */
  116. /* number of rows of m1, m2 and m3 must be equal.            */
  117. /************************************************************************/
  118.  
  119. void    RbfAddMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2, RbfFloatMatrix *m3); 
  120.  
  121. /************************************************************************/
  122. /* print out matrix m to stream (file) s                */
  123. /************************************************************************/
  124.  
  125. void    RbfPrintMatrix(RbfFloatMatrix *m, FILE *s);
  126.  
  127. /************************************************************************/
  128. /* print message to stderr                                    */
  129. /************************************************************************/
  130.  
  131. void    ErrMess(char *message);
  132.  
  133. /************************************************************************/
  134. /* macro definitions                            */
  135. /************************************************************************/
  136.  
  137. /************************************************************************/
  138. /* set element at row r and column c in matrix referenced by m to the   */
  139. /* value of v. r goes from 0 to rows -1, c goes from 0 to columns -1    */
  140. /************************************************************************/
  141.  
  142. #define    RbfMatrixSetValue(m, r, c, v)    ((m)->r_pt)[r][c] = v
  143.  
  144. /************************************************************************/
  145. /* get value of element at row r and column c in matrix referenced by m.*/
  146. /* r goes from 0 to rows -1, c goes from 0 to columns -1        */
  147. /************************************************************************/
  148.  
  149. #define RbfMatrixGetValue(m, r, c)    (((m) -> r_pt)[r][c])
  150.  
  151. /* end global definition section */
  152.  
  153. /* begin private definition section */
  154.  
  155. #define RBF_MATRIX_LUDCOMP    1
  156.  
  157. /* end private definition section */
  158.  
  159. #endif
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.